package com.anti.activiti.example;

import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.delegate.JavaDelegate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * @Author: anTi
 * @Date: 2019/3/18 15:33
 * @Description:服务任务实现JavaDelegate
 * @version: 1.0
 */
public class MyJavaDelegate implements JavaDelegate, Serializable {
    private static final Logger LOGGER = LoggerFactory.getLogger(MyJavaDelegate.class);



    private Expression name;
    private Expression desc;



    /**
     * 实现JavaDelegate  任务会直接执行不会等待
     * @param delegateExecution
     */
    @Override
    public void execute(DelegateExecution delegateExecution) {
        if (name!=null){
            Object value = name.getValue(delegateExecution);
            LOGGER.info("name = {}",value);
        }
        if (desc!=null){
            Object value = desc.getValue(delegateExecution);
            LOGGER.info("desc = {}",value);
        }
        LOGGER.info("run my java delegate {}",this);

    }
}
